import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  base: "/",
  publicDir: 'public',
  server: {
    // host: "0.0.0.0"
    port: 9718,
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')//设置别名
    }
  },
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    assetsInlineLimit: 4096,
    cssCodeSplit: true,
    //brotliSize: false,
    sourcemap: false,
    minify: 'terser',
    terserOptions: {
      compress: {
        // 生产环境去除console及debug
        drop_console: false,
        drop_debugger: true,
      },
    },
    chunkSizeWarningLimit:1500,
    rollupOptions: {
      output:{
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return id.toString().split('node_modules/')[1].split('/')[0].toString();
          }
        }
      }
    }
  },
})
